<?php
/**
 * Geocontexter
 * @link http://code.google.com/p/geocontexter/
 * @package Geocontexter
 */

/**
 * Admin index controller
 *
 *
 * @package Geocontexter
 * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
 * @author Armand Turpel <geocontexter@gmail.com>
 * @version $Rev$ / $LastChangedDate$ / $LastChangedBy$
 */

namespace Youobserve\Controller;

use Zend\View\Model\ViewModel;
use Youobserve\Controller\AbstractController;


class ContactController extends AbstractController
{

    protected function init($controller)
    {
        $this->initView( 'youobserve/contact/index.phtml', true );

        $this->view->partialData = array('active_page'    => 'contact',
                                         'basePath'       => $this->getBaseUrl(),
                                         'logged_user'    => $this->view->logged_user);

        $this->view->error = array();
    }

    public function indexAction()
    {

        $this->view->loop         = rand(0, 765645432);
        $this->view->loop_count   = 30;
        $this->view->loop_display = $this->view->loop + rand(1, $this->view->loop_count);

        $this->sessionOffsetSet('loop_display', $this->view->loop_display);

        return $this->view;
    }

    /**
     * perform on the login request
     *
     */
    public function dosAction()
    {
        $loop_display = '_' . $this->sessionOffsetGet('loop_display');

        $submit = $this->request->getPost()->$loop_display;

        if (($submit !== null) && !empty($submit)) {
            $this->view->sent = true;
        }

        $this->sessionOffsetUnset('loop_display');

        return $this->indexAction();
    }
}
